<?php
//按钮

namespace App\Models\Traits;


trait Btn
{
    public function editBtn(string $tar_route) {

        if (auth()->user()->username != config('rbac.super')) {
//            dd(request()->can_routes);
            $can_routes = request()->can_routes;
            if (!in_array($tar_route, $can_routes)) {
                return "";
            }
        }
        return '<a href="' . route($tar_route, $this) . '" class="label label-success radius">修改</a>';
    }

    public function deleteBtn(string $tar_route) {

        if (auth()->user()->username != config('rbac.super')) {
//            dd(request()->can_routes);
            $can_routes = request()->can_routes;
            if (!in_array($tar_route, $can_routes)) {
                return "";
            }
        }
        return '<a href="' . route($tar_route, $this) . '" class="label label-danger radius">删除</a>';
    }
}
